home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / OTPLASMA.ZIP / plasma.asm < prev    next >
Assembly Source File  |  1996-06-20  |  5KB  |  183 lines

  1. ; Plasma in 100% (t)asm
  2. ; By Vulture/Outlaw Triad
  3.  
  4. ; Derived from example code by Jare/VangelisTeam
  5.  
  6. IDEAL
  7. DOSSEG
  8. MODEL SMALL
  9. P386
  10. JUMPS
  11.  
  12. SEGMENT CODE                    ; Code segment starts
  13. ASSUME cs:code,ds:code          ; Let cs and ds point to code segment
  14.  
  15. ORG 100h
  16.  
  17. ; ─────────────────────────────[ Main Program ]─────────────────────────────────
  18.  
  19. START:
  20.  
  21.     mov     ax,0a000h
  22.     mov     es,ax
  23.  
  24.     call    Set_Vga
  25.  
  26. Main_Loop:                      ; Go into mainloop
  27.     call    Do_Plasma
  28.     call    WaitVrt
  29.     in      al,60h              ; Scan keyboard
  30.     cmp     al,1
  31.     jne     Main_Loop           ; Quit on escape
  32.  
  33. ; === Quit to DOS ===
  34.     mov     ax,0003h            ; Back to textmode
  35.     int     10h
  36.     lea     dx,[Credits]
  37.     mov     ah,09h
  38.     int     21h
  39.     ret
  40.  
  41. ; ─────────────────────────────[ Sub Routines ]─────────────────────────────────
  42.  
  43. PROC WaitVrt
  44.     mov     dx,3dah
  45. Vrt:
  46.     in      al,dx
  47.     test    al,1000b
  48.     jnz     Vrt                 ; Wait until Verticle Retrace starts
  49. NoVrt:
  50.     in      al,dx
  51.     test    al,1000b
  52.     jz      NoVrt               ; Wait until Verticle Retrace ends
  53.     ret
  54. ENDP WaitVrt
  55.  
  56. PROC Set_Vga
  57.     mov     ax,0013h            ; Videomode 13h  320*200*256
  58.     int     10h                 ; Set the mode
  59.  
  60. ; === Reprogram vga registers ===
  61.     mov     dx,03c4h            ; Sequencer Register
  62.     mov     ax,0604h
  63.     out     dx,ax               ; Disable chain4 bit
  64.     mov     dx,03d4h            ; CrtC register
  65.     mov     ax,0014h
  66.     out     dx,ax               ; Turn off double word mode
  67.     mov     ax,0e317h
  68.     out     dx,ax               ; Turn on byte mode
  69.     mov     ax,04709h
  70.     out     dx,ax               ; Duplicate scanlines
  71.  
  72. ; === Clear VGA memory ===
  73.     mov     dx,03c4h            ; Select port 03c4h
  74.     mov     ax,00f02h           ; Map Mask Register (select all planes)
  75.     out     dx,ax
  76.     mov     ax,0a000h           ; VGA segment
  77.     mov     es,ax
  78.     xor     di,di               ; Set es:di to point to screenmem  di=0
  79.     xor     ax,ax               ; Color to store = usually black = 0
  80.     mov     cx,32768            ; 32768 words * 2 = 65536 bytes = 1 plane
  81.     rep     stosw               ; Clear all 4 planes using wordwrites
  82.  
  83. ; === Set palette ===
  84.     lea     si,[Plasma_Palette]
  85.     mov     dx,03c8h
  86.     xor     al,al
  87.     out     dx,al
  88.     inc     dx
  89.     mov     cx,128*3
  90.     repz    outsb
  91.  
  92.     ret
  93. ENDP Set_Vga
  94.  
  95. PROC Do_Plasma
  96.     xor     di,di               ; Reset vga position
  97.  
  98.     mov     cl,[Co1]            ; Vertical cosine start values
  99.     mov     ch,[Co2]
  100.  
  101.     mov     ah,50               ; 50 scanlines
  102. @Outer_Plasma:
  103.     push    ax
  104.  
  105.     mov     dl,[Co3]            ; Horizontal cosine start values
  106.     mov     dh,[Co4]
  107.  
  108.     mov     ah,80               ; 80 pixels on 1 scanline
  109. @Inner_Plasma:
  110.     mov     al,50               ; Initial value (experiment with thiz!)
  111.     add     al,ah
  112.     xor     bh,bh
  113.  
  114.     mov     bl,dl               ; Add 4 cosine values
  115.     add     al,[Cosine+bx]
  116.     mov     bl,dh
  117.     add     al,[Cosine+bx]
  118.     mov     bl,cl
  119.     add     al,[Cosine+bx]
  120.     mov     bl,ch
  121.     add     al,[Cosine+bx]
  122.     and     al,01111111b
  123.     stosb                       ; Write resulting value to [es:di]
  124.     add     dl,1
  125.     add     dh,2
  126.     dec     ah                  ; Next pixel on horizontal line
  127.     jnz     @Inner_Plasma
  128.  
  129.     add     cl,3
  130.     add     ch,4
  131.     pop     ax
  132.     dec     ah                  ; Next horizontal line
  133.     jnz     @Outer_Plasma
  134.  
  135.     sub     [Co1],4
  136.     add     [Co2],3
  137.     sub     [Co3],2
  138.     add     [Co4],1
  139.  
  140.     ret
  141. ENDP Do_Plasma
  142.  
  143. ; ─────────────────────────────────[ Data ]─────────────────────────────────────
  144.  
  145. INCLUDE "cosine.dat"
  146.  
  147. Label Credits Byte
  148.         db 13,10,"▄  ▄▄  ▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄  ▄▄  ▄"
  149.         db 13,10,"                    - An Outlaw Triad Production (c) 1996 -",13,10
  150.         db 13,10,"                             Code∙∙∙∙∙∙∙∙∙∙Vulture" ,13,10
  151.         db 13,10,"                            -=≡ Outlaw Triad Is ≡=-",13,10
  152.         db 13,10,"  Vulture(code) ■ Dazl(artist) ■ Troop(sysop) ■ Xplorer(artist) ■ Inopia(code)",13,10
  153.         db 13,10,"▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄",13,10,"$"
  154.  
  155. Label Plasma_Palette Byte
  156.    i = 0
  157.    rept 32
  158.      db 33,i,i
  159.      i = i + 1
  160.    endm
  161.    rept 32
  162.      db i,i,33
  163.      i = i - 1
  164.    endm
  165.    rept 32
  166.      db i,i,33
  167.      i = i + 1
  168.    endm
  169.    rept 32
  170.      db 33,i,i
  171.      i = i - 1
  172.    endm
  173.  
  174. Co1  db ?
  175. Co2  db ?
  176. Co3  db ?
  177. Co4  db ?
  178.  
  179. ENDS CODE                  ; End of codesegment
  180. END START
  181.  
  182. ; ─────────────────────────────────[ The End ]──────────────────────────────────
  183.